<!doctype html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=robots content="noodp"><meta http-equiv=x-ua-compatible content="IE=edge, chrome=1"><title>Elasticsearch问题汇总 - Yulin Lewis' Blog</title><meta name=keywords content="雨临Lewis,Java,hugo,hexo,博客"><meta name=Description content="不想当写手的码农不是好咸鱼_(xз」∠)_"><meta property="og:title" content="Elasticsearch问题汇总"><meta property="og:description" content="前言
本文主要基于Elasticsearch 6.5.4版本：


1
2
3
4
5


<dependency>
  <groupId>org.elasticsearch</groupId>
  <artifactId>elasticsearch</artifactId>
  <version>6.5.4</version>
</dependency>"><meta property="og:type" content="article"><meta property="og:url" content="https://lewky.cn/posts/es-issues/"><meta property="og:image" content="https://lewky.cn/logo.png"><meta property="article:published_time" content="2021-09-08T23:44:59+08:00"><meta property="article:modified_time" content="2021-12-25T23:44:59+08:00"><meta name=twitter:card content="summary_large_image"><meta name=twitter:image content="https://lewky.cn/logo.png"><meta name=twitter:title content="Elasticsearch问题汇总"><meta name=twitter:description content="前言
本文主要基于Elasticsearch 6.5.4版本：


1
2
3
4
5


<dependency>
  <groupId>org.elasticsearch</groupId>
  <artifactId>elasticsearch</artifactId>
  <version>6.5.4</version>
</dependency>"><meta name=application-name content="雨临Lewis的博客"><meta name=apple-mobile-web-app-title content="雨临Lewis的博客"><meta name=theme-color content="#ffffff"><meta name=msapplication-TileColor content="#da532c"><link rel="shortcut icon" type=image/x-icon href=/favicon.ico><link rel=icon type=image/png sizes=32x32 href=/favicon-32x32.png><link rel=icon type=image/png sizes=16x16 href=/favicon-16x16.png><link rel=apple-touch-icon sizes=180x180 href=/apple-touch-icon.png><link rel=mask-icon href=/safari-pinned-tab.svg color=#5bbad5><link rel=manifest href=/site.webmanifest><link rel=canonical href=https://lewky.cn/posts/es-issues/><link rel=prev href=https://lewky.cn/posts/hugo-3-3/><link rel=next href=https://lewky.cn/posts/log-framework/><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/normalize.css@8.0.1/normalize.min.css><link rel=stylesheet href=/css/style.min.css><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.13.0/css/all.min.css><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/animate.css@3.7.2/animate.min.css><script type=application/ld+json>{"@context":"http://schema.org","@type":"BlogPosting","headline":"Elasticsearch问题汇总","inLanguage":"","mainEntityOfPage":{"@type":"WebPage","@id":"https:\/\/lewky.cn\/posts\/es-issues\/"},"genre":"posts","keywords":"工作记录, Elasticsearch","wordcount":3135,"url":"https:\/\/lewky.cn\/posts\/es-issues\/","datePublished":"2021-09-08T23:44:59+08:00","dateModified":"2021-12-25T23:44:59+08:00","license":"This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.","publisher":{"@type":"Organization","name":"雨临Lewis","logo":"https:\/\/lewky.cn\/images\/avatar.jpg"},"author":{"@type":"Person","name":"雨临Lewis"},"description":""}</script></head><body header-desktop=fixed header-mobile=auto><script type=text/javascript>(window.localStorage&&localStorage.getItem('theme')?localStorage.getItem('theme')==='dark':('auto'==='auto'?window.matchMedia('(prefers-color-scheme: dark)').matches:'auto'==='dark'))&&document.body.setAttribute('theme','dark');</script><div id=mask></div><div class=wrapper><header class=desktop id=header-desktop><div class=header-wrapper><a href=https://github.com/lewky class=github-corner target=_blank title="Follow me on GitHub" aria-label="Follow me on GitHub"><svg width="3.5rem" height="3.5rem" viewBox="0 0 250 250" style="fill:#70b7fd;color:#fff;position:absolute;top:0;border:0;left:0;transform:scale(-1,1)" aria-hidden="true"><path d="M0 0 115 115h15l12 27L250 250V0z"/><path d="M128.3 109C113.8 99.7 119 89.6 119 89.6 122 82.7 120.5 78.6 120.5 78.6 119.2 72 123.4 76.3 123.4 76.3 127.3 80.9 125.5 87.3 125.5 87.3 122.9 97.6 130.6 101.9 134.4 103.2" fill="currentcolor" style="transform-origin:130px 106px" class="octo-arm"/><path d="M115 115C114.9 115.1 118.7 116.5 119.8 115.4L133.7 101.6C136.9 99.2 139.9 98.4 142.2 98.6 133.8 88 127.5 74.4 143.8 58 148.5 53.4 154 51.2 159.7 51 160.3 49.4 163.2 43.6 171.4 40.1 171.4 40.1 176.1 42.5 178.8 56.2 183.1 58.6 187.2 61.8 190.9 65.4 194.5 69 197.7 73.2 200.1 77.6 213.8 80.2 216.3 84.9 216.3 84.9 212.7 93.1 206.9 96 205.4 96.6 205.1 102.4 203 107.8 198.3 112.5 181.9 128.9 168.3 122.5 157.7 114.1 157.9 116.9 156.7 120.9 152.7 124.9L141 136.5C139.8 137.7 141.6 141.9 141.8 141.8z" fill="currentcolor" class="octo-body"/></svg></a><div class=header-title><a href=/ title="Yulin Lewis' Blog"><span class=header-title-pre><i class="fas fa-fw fa-atom"></i></span>雨临Lewis</a></div><div class=menu><div class=menu-inner><div class=dropdown><a href=/posts/ class="menu-item menu-more dropbtn" title=点击查看所有文章><i class="fas fa-fw fa-archive"></i>归档</a><div class="menu-more-content dropdown-content"><a href=/categories/><i class="fas fa-fw fa-th"></i>分类 </a><a href=/tags/><i class="fas fa-fw fa-tag"></i>标签 </a><a href=/hot/ title=文章热度Top15><i class="fas fa-fw fa-fire"></i>热度 </a><a href=/donation/ title=感谢打赏，老板大气~><i class="fas fa-fw fa-donate"></i>打赏 </a><a href=/about/><i class="fas fa-fw fa-at"></i>关于</a></div></div><a class=menu-item href=/friends/ title=欢迎申请友链><i class="fas fa-fw fa-link"></i>友链</a><div class=dropdown><a href=javascript:void(0); class="menu-item menu-more dropbtn" title=一些有意思的东东~><i class="fas fa-fw fa-fan fa-spin"></i>趣味</a><div class="menu-more-content dropdown-content"><a href=/funny/high/ title="前方高能♂ 小心外放！" target=_blank rel=noopener><i class="fas fa-fw fa-dizzy"></i>燥起来！ </a><a href=/funny/mikutap/ title=初音未来音乐游戏 target=_blank rel=noopener><i class="fas fa-fw fa-music"></i>在线打碟 </a><a href=/funny/catch-the-cat/ title=逮住那只猫!><i class="fas fa-fw fa-cat"></i>抓住猫咪</a></div></div><div class=dropdown><a href=/ class="menu-item menu-more dropbtn" title=回到首页><i class="fas fa-fw fa-atom"></i>站点</a><div class="menu-more-content dropdown-content"><a href=/bbs/ title=来留言吧~><i class="fas fa-fw fa-comment"></i>公告留言 </a><a href=https://seo.chinaz.com target=_blank rel=noopener><i class="fas fa-fw fa-chart-line"></i>SEO查询 </a><a href=https://www.ping.cn/http/lewky.cn target=_blank rel=noopener><i class="fas fa-fw fa-bezier-curve"></i>网站测速 </a><a href=/posts/e62c38c4.html/><i class="fas fa-fw fa-cog fa-spin"></i>建站日志</a></div></div><div class=dropdown><a href=javascript:void(0); class="menu-item menu-more dropbtn"><i class="fas fa-fw fa-book"></i>文档</a><div class="menu-more-content dropdown-content"><a href=https://gohugo.io/documentation/ target=_blank rel=noopener><i class="fas fa-fw fa-star"></i>Hugo文档 </a><a href=https://javanote.doc.lewky.cn/ title=尚在完善中~ target=_blank rel=noopener><i class="fab fa-fw fa-java"></i>Java 笔记</a></div></div><a class=menu-item href=/search/ title=渲染搜索结果需要等待几秒钟~><i class="fas fa-fw fa-search"></i>搜索
</a><span class="menu-item delimiter"></span><a href=https://travellings.link target=_blank class=menu-item rel=noopener title=开往-友链接力><i class="fas fa-fw fa-subway"></i></a><a href=https://rssblog.vercel.app/ class=menu-item target=_blank rel=noopener title=RSSBlog><i class="fas fa-fw fa-inbox"></i></a><a href=https://github.com/lewky class=menu-item target=_blank rel=noopener title=GitHub><i class="fab fa-fw fa-github"></i></a></div></div></div></header><header class=mobile id=header-mobile><div class=header-container><div class=header-wrapper><div class=header-title><a href=/ title="Yulin Lewis' Blog"><span class=header-title-pre><i class="fas fa-fw fa-atom"></i></span>雨临Lewis</a></div><div class=menu-toggle id=menu-toggle-mobile><span></span><span></span><span></span></div></div><div class=menu id=menu-mobile><div class=dropdown><a href=/posts/ class="menu-item menu-more dropbtn" title=点击查看所有文章><i class="fas fa-fw fa-archive"></i>归档</a><div class="menu-more-content dropdown-content"><a href=/categories/><i class="fas fa-fw fa-th"></i>分类 </a><a href=/tags/><i class="fas fa-fw fa-tag"></i>标签 </a><a href=/hot/ title=文章热度Top15><i class="fas fa-fw fa-fire"></i>热度 </a><a href=/donation/ title=感谢打赏，老板大气~><i class="fas fa-fw fa-donate"></i>打赏 </a><a href=/about/><i class="fas fa-fw fa-at"></i>关于</a></div></div><a class=menu-item href=/friends/ title=欢迎申请友链><i class="fas fa-fw fa-link"></i>友链</a><div class=dropdown><a href=javascript:void(0); class="menu-item menu-more dropbtn" title=一些有意思的东东~><i class="fas fa-fw fa-fan fa-spin"></i>趣味</a><div class="menu-more-content dropdown-content"><a href=/funny/high/ title="前方高能♂ 小心外放！" target=_blank rel=noopener><i class="fas fa-fw fa-dizzy"></i>燥起来！ </a><a href=/funny/mikutap/ title=初音未来音乐游戏 target=_blank rel=noopener><i class="fas fa-fw fa-music"></i>在线打碟 </a><a href=/funny/catch-the-cat/ title=逮住那只猫!><i class="fas fa-fw fa-cat"></i>抓住猫咪</a></div></div><div class=dropdown><a href=/ class="menu-item menu-more dropbtn" title=回到首页><i class="fas fa-fw fa-atom"></i>站点</a><div class="menu-more-content dropdown-content"><a href=/bbs/ title=来留言吧~><i class="fas fa-fw fa-comment"></i>公告留言 </a><a href=https://seo.chinaz.com target=_blank rel=noopener><i class="fas fa-fw fa-chart-line"></i>SEO查询 </a><a href=https://www.ping.cn/http/lewky.cn target=_blank rel=noopener><i class="fas fa-fw fa-bezier-curve"></i>网站测速 </a><a href=/posts/e62c38c4.html/><i class="fas fa-fw fa-cog fa-spin"></i>建站日志</a></div></div><div class=dropdown><a href=javascript:void(0); class="menu-item menu-more dropbtn"><i class="fas fa-fw fa-book"></i>文档</a><div class="menu-more-content dropdown-content"><a href=https://gohugo.io/documentation/ target=_blank rel=noopener><i class="fas fa-fw fa-star"></i>Hugo文档 </a><a href=https://javanote.doc.lewky.cn/ title=尚在完善中~ target=_blank rel=noopener><i class="fab fa-fw fa-java"></i>Java 笔记</a></div></div><a class=menu-item href=/search/ title=渲染搜索结果需要等待几秒钟~><i class="fas fa-fw fa-search"></i>搜索</a>
<a href=https://travellings.link target=_blank class=menu-item rel=noopener title=开往-友链接力><i class="fas fa-fw fa-subway"></i></a><a href=https://rssblog.vercel.app/ class=menu-item target=_blank rel=noopener title=RSSBlog><i class="fas fa-fw fa-inbox"></i></a><a href=https://github.com/lewky class=menu-item target=_blank rel=noopener title=GitHub><i class="fab fa-fw fa-github"></i></a></div></div></header><div class="search-dropdown desktop"><div id=search-dropdown-desktop></div></div><div class="search-dropdown mobile"><div id=search-dropdown-mobile></div></div><main class=main><div class=container><div class=toc id=toc-auto><h2 class=toc-title>目录</h2><div class=toc-content id=toc-content-auto></div></div><article class="page single"><h1 class="single-title animated flipInX">Elasticsearch问题汇总</h1><div class=post-meta><div class=post-meta-line><span class=post-author><a href=/ title=Author rel=author class=author><i class="fas fa-user-circle fa-fw"></i>雨临Lewis</a></span>&nbsp;<span class=post-category>收录于 <a href=/categories/%E5%B7%A5%E4%BD%9C%E8%AE%B0%E5%BD%95/><i class="far fa-folder fa-fw"></i>工作记录</a></span></div><div class=post-meta-line><i class="far fa-calendar fa-fw"></i>&nbsp;<time datetime=2021-09-08>2021-09-08</time>&nbsp;<i class="far fa-calendar-plus fa-fw"></i>&nbsp;<time datetime=2021-12-25>2021-12-25</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;约 3135 字
<i class="far fa-clock fa-fw"></i>&nbsp;预计阅读 7 分钟&nbsp;<span id=/posts/es-issues/ class=leancloud_visitors data-flag-title=Elasticsearch问题汇总>
<i class="far fa-eye fa-fw"></i>&nbsp;<span class=leancloud-visitors-count></span>&nbsp;次阅读
</span>&nbsp;
<a href=#comments id=post-meta-vcount title=查看评论><i class="fas fa-comment fa-fw"></i>&nbsp;<span id=/posts/es-issues/ class=waline-comment-count></span>&nbsp;条评论</a></div></div><div class="details toc" id=toc-static kept><div class="details-summary toc-title"><span>目录</span>
<span><i class="details-icon fas fa-angle-right"></i></span></div><div class="details-content toc-content" id=toc-content-static><nav id=TableOfContents><ol><li><a href=#前言>前言</a></li><li><a href=#too_many_clauses问题>too_many_clauses问题</a></li><li><a href=#修改jvm参数>修改jvm参数</a></li><li><a href=#cannot-write-xcontent-for-unknown-value-of-type-class-javamathbigdecimal>cannot write xcontent for unknown value of type class java.math.BigDecimal</a><ol><li><a href=#解决方案一转变成其他es支持的数据类型>解决方案一：转变成其他ES支持的数据类型</a></li><li><a href=#解决方案二使用更高版本的es>解决方案二：使用更高版本的ES</a></li></ol></li><li><a href=#limit-of-total-fields-1000-in-index-has-been-exceeded>Limit of total fields [1000] in index has been exceeded</a></li><li><a href=#forbidden12index-read-only--allow-delete-api>FORBIDDEN/12/index read-only / allow delete (api)</a></li><li><a href=#result-window-is-too-large>Result window is too large</a></li><li><a href=#failed-to-parse-date-field>failed to parse date field</a></li><li><a href=#request-size-exceeded-104857600-bytes>Request size exceeded 104857600 bytes</a></li><li><a href=#参考链接>参考链接</a></li></ol></nav></div></div><div class=content id=content><h2 id=前言>前言</h2><p>本文主要基于Elasticsearch 6.5.4版本：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span><span class=lnt>2
</span><span class=lnt>3
</span><span class=lnt>4
</span><span class=lnt>5
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-fallback data-lang=fallback>&lt;dependency&gt;
  &lt;groupId&gt;org.elasticsearch&lt;/groupId&gt;
  &lt;artifactId&gt;elasticsearch&lt;/artifactId&gt;
  &lt;version&gt;6.5.4&lt;/version&gt;
&lt;/dependency&gt;
</code></pre></td></tr></table></div></div><h2 id=too_many_clauses问题>too_many_clauses问题</h2><p>Elasticsearch查询时报错如下：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span><span class=lnt>2
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-fallback data-lang=fallback>&#34;caused_by&#34;:{&#34;type&#34;:&#34;too_many_clauses&#34;,&#34;reason&#34;:&#34;maxClauseCount is set to 1024&#34;}}}],
&#34;caused_by&#34;:{&#34;type&#34;:&#34;query_shard_exception&#34;,&#34;reason&#34;:&#34;failed to create query:
</code></pre></td></tr></table></div></div><p>这是bool查询的条件超过了默认的1024上限，可以通过修改全局配置来增加上限，需要注意的是别设置太高，会消耗太多的CPU资源和内存。</p><p>打开ES的配置文件<code>/config/elasticsearch.yml</code>，增加配置：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-fallback data-lang=fallback>indices.query.bool.max_clause_count: 2048
</code></pre></td></tr></table></div></div><p>修改全局配置后需要重启ES才能生效。如果不允许重启ES集群，就只能从查询语句入手了，要么削减查询条件的数量，要么将查询条件转移到<code>must_not</code>的<code>terms</code>查询中。</p><p><code>must_not</code>的<code>terms</code>查询可以超过默认的1024上限，对于肯定条件可以用<code>must_not</code>嵌套<code>must_not</code>来实现。（这种做法是其他博主验证的，这里只提一嘴，在短期内无法重启ES集群时可以作为临时方案使用。）</p><h2 id=修改jvm参数>修改jvm参数</h2><p>Elasticsearch是用Java开发的，默认会配置1G的jvm堆的初始值和最大值，该jvm参数被配置在<code>/config/jvm.options</code>里：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span><span class=lnt>2
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-fallback data-lang=fallback>-Xms1g
-Xmx1g
</code></pre></td></tr></table></div></div><p>如果只是个人开发小项目，可以把参数改小些（当然不能调整太小，内存对于ES的性能影响较大），比如：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span><span class=lnt>2
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-fallback data-lang=fallback>-Xms512m
-Xmx512m
</code></pre></td></tr></table></div></div><p>这个<code>jvm.options</code>用来配置各种jvm参数，比如GC、GC logging、heap dumps等。</p><h2 id=cannot-write-xcontent-for-unknown-value-of-type-class-javamathbigdecimal>cannot write xcontent for unknown value of type class java.math.BigDecimal</h2><p>Elasticsearch在索引数据时报错如下：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt> 1
</span><span class=lnt> 2
</span><span class=lnt> 3
</span><span class=lnt> 4
</span><span class=lnt> 5
</span><span class=lnt> 6
</span><span class=lnt> 7
</span><span class=lnt> 8
</span><span class=lnt> 9
</span><span class=lnt>10
</span><span class=lnt>11
</span><span class=lnt>12
</span><span class=lnt>13
</span><span class=lnt>14
</span><span class=lnt>15
</span><span class=lnt>16
</span><span class=lnt>17
</span><span class=lnt>18
</span><span class=lnt>19
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-java data-lang=java><span class=n>java</span><span class=o>.</span><span class=na>lang</span><span class=o>.</span><span class=na>IllegalArgumentException</span><span class=o>:</span> <span class=n>cannot</span> <span class=n>write</span> <span class=n>xcontent</span> <span class=k>for</span> <span class=n>unknown</span> <span class=n>value</span> <span class=n>of</span> <span class=n>type</span> <span class=kd>class</span> <span class=nc>java</span><span class=o>.</span><span class=na>math</span><span class=o>.</span><span class=na>BigDecimal</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>common</span><span class=o>.</span><span class=na>xcontent</span><span class=o>.</span><span class=na>XContentBuilder</span><span class=o>.</span><span class=na>unknownValue</span><span class=o>(</span><span class=n>XContentBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>755</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>common</span><span class=o>.</span><span class=na>xcontent</span><span class=o>.</span><span class=na>XContentBuilder</span><span class=o>.</span><span class=na>value</span><span class=o>(</span><span class=n>XContentBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>726</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>common</span><span class=o>.</span><span class=na>xcontent</span><span class=o>.</span><span class=na>XContentBuilder</span><span class=o>.</span><span class=na>field</span><span class=o>(</span><span class=n>XContentBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>711</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>index</span><span class=o>.</span><span class=na>query</span><span class=o>.</span><span class=na>BaseTermQueryBuilder</span><span class=o>.</span><span class=na>doXContent</span><span class=o>(</span><span class=n>BaseTermQueryBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>154</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>index</span><span class=o>.</span><span class=na>query</span><span class=o>.</span><span class=na>AbstractQueryBuilder</span><span class=o>.</span><span class=na>toXContent</span><span class=o>(</span><span class=n>AbstractQueryBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>82</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>index</span><span class=o>.</span><span class=na>query</span><span class=o>.</span><span class=na>BoolQueryBuilder</span><span class=o>.</span><span class=na>doXArrayContent</span><span class=o>(</span><span class=n>BoolQueryBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>275</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>index</span><span class=o>.</span><span class=na>query</span><span class=o>.</span><span class=na>BoolQueryBuilder</span><span class=o>.</span><span class=na>doXContent</span><span class=o>(</span><span class=n>BoolQueryBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>256</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>index</span><span class=o>.</span><span class=na>query</span><span class=o>.</span><span class=na>AbstractQueryBuilder</span><span class=o>.</span><span class=na>toXContent</span><span class=o>(</span><span class=n>AbstractQueryBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>82</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>common</span><span class=o>.</span><span class=na>xcontent</span><span class=o>.</span><span class=na>XContentBuilder</span><span class=o>.</span><span class=na>value</span><span class=o>(</span><span class=n>XContentBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>779</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>common</span><span class=o>.</span><span class=na>xcontent</span><span class=o>.</span><span class=na>XContentBuilder</span><span class=o>.</span><span class=na>value</span><span class=o>(</span><span class=n>XContentBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>772</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>common</span><span class=o>.</span><span class=na>xcontent</span><span class=o>.</span><span class=na>XContentBuilder</span><span class=o>.</span><span class=na>field</span><span class=o>(</span><span class=n>XContentBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>764</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>search</span><span class=o>.</span><span class=na>builder</span><span class=o>.</span><span class=na>SearchSourceBuilder</span><span class=o>.</span><span class=na>toXContent</span><span class=o>(</span><span class=n>SearchSourceBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>1184</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>common</span><span class=o>.</span><span class=na>xcontent</span><span class=o>.</span><span class=na>XContentHelper</span><span class=o>.</span><span class=na>toXContent</span><span class=o>(</span><span class=n>XContentHelper</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>349</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>search</span><span class=o>.</span><span class=na>builder</span><span class=o>.</span><span class=na>SearchSourceBuilder</span><span class=o>.</span><span class=na>toString</span><span class=o>(</span><span class=n>SearchSourceBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>1558</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>search</span><span class=o>.</span><span class=na>builder</span><span class=o>.</span><span class=na>SearchSourceBuilder</span><span class=o>.</span><span class=na>toString</span><span class=o>(</span><span class=n>SearchSourceBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>1553</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>java</span><span class=o>.</span><span class=na>lang</span><span class=o>.</span><span class=na>String</span><span class=o>.</span><span class=na>valueOf</span><span class=o>(</span><span class=n>String</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>2994</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>java</span><span class=o>.</span><span class=na>lang</span><span class=o>.</span><span class=na>StringBuilder</span><span class=o>.</span><span class=na>append</span><span class=o>(</span><span class=n>StringBuilder</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>131</span><span class=o>)</span>
	<span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>action</span><span class=o>.</span><span class=na>search</span><span class=o>.</span><span class=na>SearchRequest</span><span class=o>.</span><span class=na>toString</span><span class=o>(</span><span class=n>SearchRequest</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>516</span><span class=o>)</span>
</code></pre></td></tr></table></div></div><p>从异常信息看，显然ES无法接受BigDecimal类型，经过百度，也确实如此。在一篇博文评论中解释如下：</p><blockquote><p>应该是客户端代码里将查询的数值定义成了java.math.BigDecimal，而ES不支持这个类型。之所以2.2没有问题，是因为之前的transport client发送数据之前将其序列化成了json，而在5.x以后，使用的内部的transport protocol，数据类型如果不匹配会抛错误。</p><p>所以数据类型的定义上，需要使用ES支持的类型。</p></blockquote><h3 id=解决方案一转变成其他es支持的数据类型>解决方案一：转变成其他ES支持的数据类型</h3><p>我使用的是6.5.4版本的Elasticsearch，该版本尚不支持BigDecimal或者BigInteger的数据类型，所以在index到Elasticsearch之前，需要转换成其他数据类型，这里要注意不要数据溢出了:</p><ol><li>BigDecimal要转变成Double类型</li><li>BigInteger要转变成Long类型</li></ol><h3 id=解决方案二使用更高版本的es>解决方案二：使用更高版本的ES</h3><p>我在看6.7.1版本的Elasticsearch源码时发现已经可以支持BigDecimal或者BigInteger的数据类型了，所以直接使用该版本或更高版本的就行了。</p><p>下面附上两个版本的支持的数据类型的源码：</p><ul><li>6.5.4版本的Elasticsearch相关源码</li></ul><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt> 1
</span><span class=lnt> 2
</span><span class=lnt> 3
</span><span class=lnt> 4
</span><span class=lnt> 5
</span><span class=lnt> 6
</span><span class=lnt> 7
</span><span class=lnt> 8
</span><span class=lnt> 9
</span><span class=lnt>10
</span><span class=lnt>11
</span><span class=lnt>12
</span><span class=lnt>13
</span><span class=lnt>14
</span><span class=lnt>15
</span><span class=lnt>16
</span><span class=lnt>17
</span><span class=lnt>18
</span><span class=lnt>19
</span><span class=lnt>20
</span><span class=lnt>21
</span><span class=lnt>22
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-java data-lang=java><span class=n>Map</span><span class=o>&lt;</span><span class=n>Class</span><span class=o>&lt;?&gt;,</span> <span class=n>Writer</span><span class=o>&gt;</span> <span class=n>writers</span> <span class=o>=</span> <span class=k>new</span> <span class=n>HashMap</span><span class=o>&lt;&gt;();</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Boolean</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Boolean</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Byte</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Byte</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>byte</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=kt>byte</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Date</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=n>XContentBuilder</span><span class=o>::</span><span class=n>timeValue</span><span class=o>);</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Double</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Double</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>double</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=kt>double</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Float</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Float</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>float</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=kt>float</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Integer</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Integer</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>int</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=kt>int</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Long</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Long</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>long</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=kt>long</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Short</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Short</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>short</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=kt>short</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>String</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>String</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>String</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=n>String</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Locale</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>(</span><span class=n>v</span><span class=o>.</span><span class=na>toString</span><span class=o>()));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Class</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>(</span><span class=n>v</span><span class=o>.</span><span class=na>toString</span><span class=o>()));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>ZonedDateTime</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>(</span><span class=n>v</span><span class=o>.</span><span class=na>toString</span><span class=o>()));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Calendar</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=n>XContentBuilder</span><span class=o>::</span><span class=n>timeValue</span><span class=o>);</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>GregorianCalendar</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=n>XContentBuilder</span><span class=o>::</span><span class=n>timeValue</span><span class=o>);</span>
</code></pre></td></tr></table></div></div><ul><li>6.7.1版本的Elasticsearch相关源码</li></ul><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt> 1
</span><span class=lnt> 2
</span><span class=lnt> 3
</span><span class=lnt> 4
</span><span class=lnt> 5
</span><span class=lnt> 6
</span><span class=lnt> 7
</span><span class=lnt> 8
</span><span class=lnt> 9
</span><span class=lnt>10
</span><span class=lnt>11
</span><span class=lnt>12
</span><span class=lnt>13
</span><span class=lnt>14
</span><span class=lnt>15
</span><span class=lnt>16
</span><span class=lnt>17
</span><span class=lnt>18
</span><span class=lnt>19
</span><span class=lnt>20
</span><span class=lnt>21
</span><span class=lnt>22
</span><span class=lnt>23
</span><span class=lnt>24
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-java data-lang=java><span class=n>Map</span><span class=o>&lt;</span><span class=n>Class</span><span class=o>&lt;?&gt;,</span> <span class=n>Writer</span><span class=o>&gt;</span> <span class=n>writers</span> <span class=o>=</span> <span class=k>new</span> <span class=n>HashMap</span><span class=o>&lt;&gt;();</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Boolean</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Boolean</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Byte</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Byte</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>byte</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=kt>byte</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Date</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=n>XContentBuilder</span><span class=o>::</span><span class=n>timeValue</span><span class=o>);</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Double</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Double</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>double</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=kt>double</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Float</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Float</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>float</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=kt>float</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Integer</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Integer</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>int</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=kt>int</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Long</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Long</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>long</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=kt>long</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Short</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>Short</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=kt>short</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=kt>short</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>String</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>String</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>String</span><span class=o>[].</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>values</span><span class=o>((</span><span class=n>String</span><span class=o>[])</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Locale</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>(</span><span class=n>v</span><span class=o>.</span><span class=na>toString</span><span class=o>()));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Class</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>(</span><span class=n>v</span><span class=o>.</span><span class=na>toString</span><span class=o>()));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>ZonedDateTime</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>(</span><span class=n>v</span><span class=o>.</span><span class=na>toString</span><span class=o>()));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>Calendar</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=n>XContentBuilder</span><span class=o>::</span><span class=n>timeValue</span><span class=o>);</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>GregorianCalendar</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=n>XContentBuilder</span><span class=o>::</span><span class=n>timeValue</span><span class=o>);</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>BigInteger</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>BigInteger</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
<span class=n>writers</span><span class=o>.</span><span class=na>put</span><span class=o>(</span><span class=n>BigDecimal</span><span class=o>.</span><span class=na>class</span><span class=o>,</span> <span class=o>(</span><span class=n>b</span><span class=o>,</span> <span class=n>v</span><span class=o>)</span> <span class=o>-&gt;</span> <span class=n>b</span><span class=o>.</span><span class=na>value</span><span class=o>((</span><span class=n>BigDecimal</span><span class=o>)</span> <span class=n>v</span><span class=o>));</span>
</code></pre></td></tr></table></div></div><p>可以发现，在6.7.1版本的源码里，多出了最后的两种数据类型的支持：BigInteger和BigDecimal。</p><h2 id=limit-of-total-fields-1000-in-index-has-been-exceeded>Limit of total fields [1000] in index has been exceeded</h2><p>在索引数据时ES抛出异常：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-fallback data-lang=fallback>cause: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Limit of total fields [1000] in index [item] has been exceeded]]
</code></pre></td></tr></table></div></div><p>这是由于被索引的文档字段数量超过了默认的1000上限，两种解决方法，要么减少文档的字段，要么增加字段上限。</p><p>增加字段上限可以只设置某个索引，也可以设置为全局的配置，对所有已存在的索引生效，但对之后新建的索引是无效的。</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt> 1
</span><span class=lnt> 2
</span><span class=lnt> 3
</span><span class=lnt> 4
</span><span class=lnt> 5
</span><span class=lnt> 6
</span><span class=lnt> 7
</span><span class=lnt> 8
</span><span class=lnt> 9
</span><span class=lnt>10
</span><span class=lnt>11
</span><span class=lnt>12
</span><span class=lnt>13
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-fallback data-lang=fallback>// 只设置test索引的配置
PUT http://localhost:9200/test/_settings

{
  &#34;index.mapping.total_fields.limit&#34;: 5000
}

// 全局的配置
PUT http://localhost:9200/_settings

{
  &#34;index.mapping.total_fields.limit&#34;: 5000
}
</code></pre></td></tr></table></div></div><h2 id=forbidden12index-read-only--allow-delete-api>FORBIDDEN/12/index read-only / allow delete (api)</h2><p>索引数据时报错如下：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-fallback data-lang=fallback>cause: ElasticsearchException[Elasticsearch exception [type=cluster_block_exception, reason=blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];]]
</code></pre></td></tr></table></div></div><p>这是ES节点的数据目录data磁盘空间使用率超过90%导致的，为了保护数据，ES将索引变为只读模式，只允许删除。</p><p>此时需要增大磁盘的使用空间，有如下多种方法：</p><ol><li>集群增加节点</li><li>降低集群的索引副本数量</li><li>清理磁盘无用的数据，比如日志等</li></ol><p>ES应该尽量别和其他项目部署在一起，磁盘容易被其他项目的日志挤占。此外，ES本身的日志和数据存储目录也可以配置在不同的目录，需要更改配置文件<code>/config/elasticsearch.yml</code>：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span><span class=lnt>2
</span><span class=lnt>3
</span><span class=lnt>4
</span><span class=lnt>5
</span><span class=lnt>6
</span><span class=lnt>7
</span><span class=lnt>8
</span><span class=lnt>9
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-yml data-lang=yml><span class=c># ----------------------------------- Paths ------------------------------------</span><span class=w>
</span><span class=w></span><span class=c>#</span><span class=w>
</span><span class=w></span><span class=c># Path to directory where to store the data (separate multiple locations by comma):</span><span class=w>
</span><span class=w></span><span class=c>#</span><span class=w>
</span><span class=w></span><span class=c>#path.data: /path/to/data</span><span class=w>
</span><span class=w></span><span class=c>#</span><span class=w>
</span><span class=w></span><span class=c># Path to log files:</span><span class=w>
</span><span class=w></span><span class=c>#</span><span class=w>
</span><span class=w></span><span class=c>#path.logs: /path/to/logs</span><span class=w>
</span></code></pre></td></tr></table></div></div><p>在增大了磁盘的使用空间后，索引的只读状态需要手动更改回来，可以更改所有索引，也可以只指定某个索引（用对应的索引名字取代<code>_all</code>，<code>_all</code>表示所有索引，如果不指定索引名，也不使用<code>_all</code>，同样表示修改全局配置）：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span><span class=lnt>2
</span><span class=lnt>3
</span><span class=lnt>4
</span><span class=lnt>5
</span><span class=lnt>6
</span><span class=lnt>7
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-fallback data-lang=fallback>// curl方式
curl -XPUT -H &#34;Content-Type: application/json&#34; http://localhost:9200/_all/_settings -d &#39;{&#34;index.blocks.read_only_allow_delete&#34;: null}&#39;

// RESTful方式
PUT http://localhost:9200/_all/_settings

{&#34;index.blocks.read_only_allow_delete&#34;: null}
</code></pre></td></tr></table></div></div><h2 id=result-window-is-too-large>Result window is too large</h2><p>报错如下：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span><span class=lnt>2
</span><span class=lnt>3
</span><span class=lnt>4
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-json data-lang=json><span class=s2>&#34;root_cause&#34;</span><span class=err>:</span> <span class=p>[{</span>
    <span class=nt>&#34;type&#34;</span><span class=p>:</span> <span class=s2>&#34;illegal_argument_exception&#34;</span><span class=p>,</span>
    <span class=nt>&#34;reason&#34;</span><span class=p>:</span> <span class=s2>&#34;Result window is too large, from + size must be less than or equal to: [10000] but was [80000]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting.&#34;</span>
<span class=p>}]</span>
</code></pre></td></tr></table></div></div><p>ES分页查询（from+size）默认的最大查询结果数量为10000，可以通过修改max_result_window的值来提高上限：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span><span class=lnt>2
</span><span class=lnt>3
</span><span class=lnt>4
</span><span class=lnt>5
</span><span class=lnt>6
</span><span class=lnt>7
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-fallback data-lang=fallback>// curl方式
curl -XPUT -H &#34;Content-Type: application/json&#34; http://localhost:9200/_all/_settings -d &#39;{&#34;index.max_result_window&#34; :&#34;100000&#34;}&#39;

// RESTful方式
PUT http://localhost:9200/_all/_settings

{&#34;index.max_result_window&#34; :&#34;100000&#34;}
</code></pre></td></tr></table></div></div><h2 id=failed-to-parse-date-field>failed to parse date field</h2><p>在查询es时报错如下：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt> 1
</span><span class=lnt> 2
</span><span class=lnt> 3
</span><span class=lnt> 4
</span><span class=lnt> 5
</span><span class=lnt> 6
</span><span class=lnt> 7
</span><span class=lnt> 8
</span><span class=lnt> 9
</span><span class=lnt>10
</span><span class=lnt>11
</span><span class=lnt>12
</span><span class=lnt>13
</span><span class=lnt>14
</span><span class=lnt>15
</span><span class=lnt>16
</span><span class=lnt>17
</span><span class=lnt>18
</span><span class=lnt>19
</span><span class=lnt>20
</span><span class=lnt>21
</span><span class=lnt>22
</span><span class=lnt>23
</span><span class=lnt>24
</span><span class=lnt>25
</span><span class=lnt>26
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-json data-lang=json><span class=p>{</span>
	<span class=nt>&#34;error&#34;</span><span class=p>:</span> <span class=p>{</span>
		<span class=nt>&#34;root_cause&#34;</span><span class=p>:</span> <span class=p>[{</span>
			<span class=nt>&#34;type&#34;</span><span class=p>:</span> <span class=s2>&#34;parse_exception&#34;</span><span class=p>,</span>
			<span class=nt>&#34;reason&#34;</span><span class=p>:</span> <span class=s2>&#34;failed to parse date field [2021-06-15 00:00:00] with format [strict_date_optional_time||epoch_millis]&#34;</span>
		<span class=p>}],</span>
		<span class=nt>&#34;type&#34;</span><span class=p>:</span> <span class=s2>&#34;search_phase_execution_exception&#34;</span><span class=p>,</span>
		<span class=nt>&#34;reason&#34;</span><span class=p>:</span> <span class=s2>&#34;all shards failed&#34;</span><span class=p>,</span>
		<span class=nt>&#34;phase&#34;</span><span class=p>:</span> <span class=s2>&#34;query&#34;</span><span class=p>,</span>
		<span class=nt>&#34;grouped&#34;</span><span class=p>:</span> <span class=kc>true</span><span class=p>,</span>
		<span class=nt>&#34;failed_shards&#34;</span><span class=p>:</span> <span class=p>[{</span>
			<span class=nt>&#34;shard&#34;</span><span class=p>:</span> <span class=mi>0</span><span class=p>,</span>
			<span class=nt>&#34;index&#34;</span><span class=p>:</span> <span class=s2>&#34;inspectbooking_kmt&#34;</span><span class=p>,</span>
			<span class=nt>&#34;node&#34;</span><span class=p>:</span> <span class=s2>&#34;Its-Juf2QXKEwmYYNu_aBQ&#34;</span><span class=p>,</span>
			<span class=nt>&#34;reason&#34;</span><span class=p>:</span> <span class=p>{</span>
				<span class=nt>&#34;type&#34;</span><span class=p>:</span> <span class=s2>&#34;parse_exception&#34;</span><span class=p>,</span>
				<span class=nt>&#34;reason&#34;</span><span class=p>:</span> <span class=s2>&#34;failed to parse date field [2021-06-15 00:00:00] with format [strict_date_optional_time||epoch_millis]&#34;</span><span class=p>,</span>
				<span class=nt>&#34;caused_by&#34;</span><span class=p>:</span> <span class=p>{</span>
					<span class=nt>&#34;type&#34;</span><span class=p>:</span> <span class=s2>&#34;illegal_argument_exception&#34;</span><span class=p>,</span>
					<span class=nt>&#34;reason&#34;</span><span class=p>:</span> <span class=s2>&#34;Unrecognized chars at the end of [2021-06-15 00:00:00]: [ 00:00:00]&#34;</span>
				<span class=p>}</span>
			<span class=p>}</span>
		<span class=p>}]</span>
	<span class=p>},</span>
	<span class=nt>&#34;status&#34;</span><span class=p>:</span> <span class=mi>400</span>
<span class=p>}</span>
</code></pre></td></tr></table></div></div><p>这是因为es的日期默认使用<code>strict_date_optional_time</code>和<code>epoch_millis</code>的format来匹配，前者是严格的ISO日期格式，后者是毫秒值格式。</p><p>这里由于搜索日期值使用的是<code>2021-06-15 00:00:00</code>这种格式，无法被es的日期解析器解析成上述的两种格式，因此抛出异常。要避免这种异常，要么修改mapping中日期字段的format，比如说用<code>||</code>添加新的格式；要么修改搜索日期时输入的值。</p><p>由于mapping一旦确定就无法更改，因此更推荐改变被搜索的日期值格式这种做法：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span><span class=lnt>2
</span><span class=lnt>3
</span><span class=lnt>4
</span><span class=lnt>5
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-java data-lang=java><span class=n>DateTimeFormatter</span> <span class=n>dateTimePattern</span> <span class=o>=</span> <span class=n>DateTimeFormatter</span><span class=o>.</span><span class=na>ofPattern</span><span class=o>(</span><span class=s>&#34;yyyy-MM-dd HH:mm:ss&#34;</span><span class=o>);</span>
<span class=c1>// 日期字符串是从db中获取的零时区日期
</span><span class=c1></span><span class=n>TemporalAccessor</span> <span class=n>parseDateTime</span> <span class=o>=</span> <span class=n>dateTimePattern</span><span class=o>.</span><span class=na>parse</span><span class=o>(</span><span class=s>&#34;2021-06-15 00:00:00&#34;</span><span class=o>);</span>
<span class=n>LocalDateTime</span> <span class=n>localDateTime</span> <span class=o>=</span> <span class=n>LocalDateTime</span><span class=o>.</span><span class=na>from</span><span class=o>(</span><span class=n>parseDateTime</span><span class=o>);</span>
<span class=n>DateTimeFormatter</span><span class=o>.</span><span class=na>ISO_LOCAL_DATE_TIME</span><span class=o>.</span><span class=na>format</span><span class=o>(</span><span class=n>localDateTime</span><span class=o>);</span>
</code></pre></td></tr></table></div></div><h2 id=request-size-exceeded-104857600-bytes>Request size exceeded 104857600 bytes</h2><p>在使用bulk批处理ES请求时，报错如下：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span><span class=lnt>2
</span><span class=lnt>3
</span><span class=lnt>4
</span><span class=lnt>5
</span><span class=lnt>6
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-java data-lang=java> <span class=n>URI</span> <span class=o>[/</span><span class=n>_bulk</span><span class=o>?</span><span class=n>timeout</span><span class=o>=</span><span class=n>1m</span><span class=o>],</span> <span class=n>status</span> <span class=n>line</span> <span class=o>[</span><span class=n>HTTP</span><span class=o>/</span><span class=n>1</span><span class=o>.</span><span class=na>1</span> <span class=n>413</span> <span class=n>Request</span> <span class=n>Entity</span> <span class=n>Too</span> <span class=n>Large</span><span class=o>]</span>
<span class=o>{</span><span class=s>&#34;Message&#34;</span><span class=o>:</span><span class=s>&#34;Request size exceeded 104857600 bytes&#34;</span><span class=o>}</span> 
    <span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>client</span><span class=o>.</span><span class=na>RestClient$SyncResponseListener</span><span class=o>.</span><span class=na>get</span><span class=o>(</span><span class=n>RestClient</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>926</span><span class=o>)</span>
    <span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>client</span><span class=o>.</span><span class=na>RestClient</span><span class=o>.</span><span class=na>performRequest</span><span class=o>(</span><span class=n>RestClient</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>229</span><span class=o>)</span>
    <span class=n>at</span> <span class=n>org</span><span class=o>.</span><span class=na>elasticsearch</span><span class=o>.</span><span class=na>client</span><span class=o>.</span><span class=na>RestHighLevelClient</span><span class=o>.</span><span class=na>internalPerformRequest</span><span class=o>(</span><span class=n>RestHighLevelClient</span><span class=o>.</span><span class=na>java</span><span class=o>:</span><span class=n>1593</span><span class=o>)</span>
    <span class=o>...</span>
</code></pre></td></tr></table></div></div><p>ES默认的请求内容最大值为100mb，超过100mb就会报错，可以在<code>/config/elasticsearch.yml</code>中添加如下配置：</p><div class=highlight><div class=chroma><table class=lntable><tr><td class=lntd><pre class=chroma><code><span class=lnt>1
</span></code></pre></td><td class=lntd><pre class=chroma><code class=language-yml data-lang=yml><span class=k>http.max_content_length</span><span class=p>:</span><span class=w> </span>200mb<span class=w>
</span></code></pre></td></tr></table></div></div><p>注：AWS的ES似乎没有提供修改ES配置文件的服务，在请求最大值上也只有10mb或者100mb的两种选项。</p><ul><li><a href=https://stackoverflow.com/questions/55541625/aws-elasticsearch-cluster-method-to-update-http-max-content-length target=_blank rel="noopener noreffer">AWS Elasticsearch cluster method to update <code>http.max_content_length</code>?</a></li></ul><h2 id=参考链接>参考链接</h2><ul><li><a href=https://www.elastic.co/guide/en/elasticsearch/reference/6.7/search-settings.html target=_blank rel="noopener noreffer">Elasticsearch Guide 6.7 - Search Settings</a></li><li><a href=https://blog.csdn.net/qingmou_csdn/article/details/86687041 target=_blank rel="noopener noreffer">ES 问题 ： too_many_clauses maxClauseCount is set to 1024</a></li><li><a href=https://elasticsearch.cn/question/3757 target=_blank rel="noopener noreffer">elastic search 5.4.版本，java api 调用出现：can not write type 【class java.math.BigDecimal】</a></li><li><a href=https://blog.csdn.net/qq_15713753/article/details/94436186 target=_blank rel="noopener noreffer">java.lang.IllegalArgumentException: Limit of total fields 【1000】 in index 索引名称</a></li><li><a href=https://blog.csdn.net/zheng45/article/details/92383323 target=_blank rel="noopener noreffer">ES 写索引报错 FORBIDDEN/12/index read-only / allow delete (api)解决方案</a></li><li><a href=https://blog.51cto.com/michaelkang/2164181 target=_blank rel="noopener noreffer">ES集群修改index副本数报错 ：index read-only / allow delete</a></li><li><a href=https://www.cnblogs.com/binbinyouni/p/10749985.html target=_blank rel="noopener noreffer">ES更改参数max_result_window</a></li><li><a href=https://www.jianshu.com/p/a44f6523912b target=_blank rel="noopener noreffer">Elasticsearch date 类型详解</a></li><li><a href=https://blog.csdn.net/ly_521015/article/details/88421596 target=_blank rel="noopener noreffer">hive向ES中插入数据量过大时出错：HTTP content length exceeded 104857600 bytes.</a></li></ul><div class=post-reward><input type=checkbox name=reward id=reward hidden>
<label class=reward-button for=reward>赞赏支持</label><div class=qr-code><label class=qr-code-image for=reward><img class=image src=https://cdn.jsdelivr.net/gh/lewky/lewky.github.io@master/images/common/wechat.png>
<span>微信打赏</span></label>
<label class=qr-code-image for=reward><img class=image src=https://cdn.jsdelivr.net/gh/lewky/lewky.github.io@master/images/common/alipay.png>
<span>支付宝打赏</span></label></div></div></div><div class=post-footer id=post-footer><div class=post-info><div class=post-info-line><div class=post-info-mod><span>更新于 2021-12-25</span></div><div class=post-info-license><span><a rel="license external nofollow noopener noreffer" href=https://creativecommons.org/licenses/by-nc/4.0/ target=_blank>CC BY-NC 4.0</a></span></div></div><div class=post-info-line><div class=post-info-md><span><a class=link-to-markdown href=/posts/es-issues/index.md target=_blank>阅读原始文档</a></span></div><div class=post-info-share><span><a href=javascript:void(0); title="分享到 Twitter" data-sharer=twitter data-url=https://lewky.cn/posts/es-issues/ data-title=Elasticsearch问题汇总 data-hashtags=工作记录,Elasticsearch><i class="fab fa-twitter fa-fw"></i></a><a href=javascript:void(0); title="分享到 Facebook" data-sharer=facebook data-url=https://lewky.cn/posts/es-issues/ data-hashtag=工作记录><i class="fab fa-facebook-square fa-fw"></i></a><a href=javascript:void(0); title="分享到 Hacker News" data-sharer=hackernews data-url=https://lewky.cn/posts/es-issues/ data-title=Elasticsearch问题汇总><i class="fab fa-hacker-news fa-fw"></i></a><a href=javascript:void(0); title="分享到 Line" data-sharer=line data-url=https://lewky.cn/posts/es-issues/ data-title=Elasticsearch问题汇总><i data-svg-src=https://cdn.jsdelivr.net/npm/simple-icons@2.14.0/icons/line.svg></i></a><a href=javascript:void(0); title="分享到 微博" data-sharer=weibo data-url=https://lewky.cn/posts/es-issues/ data-title=Elasticsearch问题汇总><i class="fab fa-weibo fa-fw"></i></a></span></div></div></div><div class=post-info-more><section class=post-tags><i class="fas fa-tags fa-fw"></i>&nbsp;<a href=/tags/%E5%B7%A5%E4%BD%9C%E8%AE%B0%E5%BD%95/>工作记录</a>,&nbsp;<a href=/tags/elasticsearch/>Elasticsearch</a></section><section><span><a href=javascript:void(0); onclick=window.history.back();>返回</a></span>&nbsp;|&nbsp;<span><a href=/>主页</a></span></section></div><div class=post-nav><a href=/posts/hugo-3-3/ class=prev rel=prev title="Hugo系列(3.3) - LoveIt主题美化与博客功能增强 · 第四章"><i class="fas fa-angle-left fa-fw"></i>Hugo系列(3.3) - LoveIt主题美化与博客功能增强 · 第四章</a>
<a href=/posts/log-framework/ class=next rel=next title=日志框架与门面模式>日志框架与门面模式<i class="fas fa-angle-right fa-fw"></i></a></div></div><div id=comments><div id=waline></div><script src=https://cdn.jsdelivr.net/npm/@waline/client/dist/Waline.min.js></script><script>new Waline({el:'#waline',meta:["nick","mail","link"],requiredMeta:["nick","mail"],login:"force",placeholder:"为防恶意灌水攻击，评论前需注册并登录，望见谅~",serverURL:"https://comment.lewky.cn/",avatarCDN:"https://sdn.geekzu.org/avatar/",pageSize:20,avatar:"retro",lang:"zh-CN",visitor:true,highlight:true,uploadImage:false,emoji:['https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/emoji/嘉然今天吃什么','https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/emoji/大航海嘉然','https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/emoji/向晚大魔王','https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/emoji/贝拉kira','https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/emoji/珈乐Carol','https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/emoji/乃琳Queen','https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/emoji/EveOneCat','https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo','https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/emoji/滑稽','https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/emoji/default']});</script></div></article></div></main><footer class=footer><div class=footer-container><div class=footer-line><span id=run-time></span>|
<a href=http://rssblog.vercel.app/ target=_blank rel=noopener title=RSSBlog><i class="fas fa-fw fa-inbox"></i>&nbsp;RSSBlog</a></div><div class=footer-line><i class="far fa-copyright fa-fw"></i><span itemprop=copyrightYear>2018 - 2022</span><span class=author itemprop=copyrightHolder>&nbsp;<a href=/ target=_blank>雨临Lewis</a></span>&nbsp;|&nbsp;<span class=license><a rel="license external nofollow noopener noreffer" href=https://creativecommons.org/licenses/by-nc/4.0/ target=_blank>CC BY-NC 4.0</a></span><span class=icp-splitter>&nbsp;|&nbsp;</span><br class=icp-br><span class=icp><a target=_blank href=http://www.beian.miit.gov.cn/ style=font-weight:700>粤ICP备19103822</a></span></div></div></footer></div><div id=fixed-buttons><a href=# id=back-to-top class=fixed-button title=回到顶部><i class="fas fa-arrow-up fa-fw"></i></a><a href=# id=view-comments class=fixed-button title=查看评论><i class="fas fa-comment fa-fw"></i></a></div><div class=sidebar_wo><div id=leimu><img src=https://cdn.jsdelivr.net/gh/lewky/lewky.github.io@master/images/b2t/leimuA.png alt=雷姆 onmouseover="this.src='https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/b2t/leimuB.png'" onmouseout="this.src='https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/b2t/leimuA.png'" title=回到顶部></div><div class=sidebar_wo id=lamu><img src=https://cdn.jsdelivr.net/gh/lewky/lewky.github.io@master/images/b2t/lamuA.png alt=雷姆 onmouseover="this.src='https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/b2t/lamuB.png'" onmouseout="this.src='https:\/\/cdn.jsdelivr.net\/gh\/lewky\/lewky.github.io@master/images/b2t/lamuA.png'" title=回到底部></div></div><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/lightgallery.js@1.2.0/dist/css/lightgallery.min.css><script type=text/javascript src=https://cdn.jsdelivr.net/npm/smooth-scroll@16.1.3/dist/smooth-scroll.min.js></script><script type=text/javascript src=https://cdn.jsdelivr.net/npm/lazysizes@5.2.2/lazysizes.min.js></script><script type=text/javascript src=https://cdn.jsdelivr.net/npm/lightgallery.js@1.2.0/dist/js/lightgallery.min.js></script><script type=text/javascript src=https://cdn.jsdelivr.net/npm/lg-thumbnail.js@1.2.0/dist/lg-thumbnail.min.js></script><script type=text/javascript src=https://cdn.jsdelivr.net/npm/lg-zoom.js@1.2.0/dist/lg-zoom.min.js></script><script type=text/javascript src=https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js></script><script type=text/javascript src=https://cdn.jsdelivr.net/npm/sharer.js@0.4.0/sharer.min.js></script><script type=text/javascript>window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":30},"comment":{},"lightGallery":{"actualSize":false,"exThumbImage":"data-thumbnail","hideBarsDelay":2000,"selector":".lightgallery","speed":400,"thumbContHeight":80,"thumbWidth":80,"thumbnail":true}};</script><script type=text/javascript src=/js/theme.min.js></script><script type=text/javascript src=https://cdn.jsdelivr.net/npm/jquery@2.1.3/dist/jquery.min.js></script><script type=text/javascript src=https://cdn.jsdelivr.net/npm/jquery-backstretch@2.1.18/jquery.backstretch.min.js></script><script>var $cdnPrefix="https://cdn.jsdelivr.net/gh/lewky/lewky.github.io@master";</script><script type=text/javascript src=/js/custom.js></script><script>var _hmt=_hmt||[];(function(){var hm=document.createElement("script");hm.src="https://hm.baidu.com/hm.js?6f278ed0fdb01edb3b1e7398379e5432";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(hm,s);})();</script></body></html>